﻿using Microsoft.Xrm.Sdk;

namespace CrmClient.Mapping
{
    public class CrmOption
    {
        public string Label { get; private set; }

        public OptionSetValue Value { get; private set; }

        public bool HasValue
        {
            get { return Value != null; }
        }

        public CrmOption(int? value, string label)
        {
            Label = label;
            if (value.HasValue)
                Value = new OptionSetValue(value.Value);
        }

        public override string ToString()
        {
            return string.Format("{0} ({1})", Label, HasValue ? Value.Value.ToString() : string.Empty);
        }
    }
}
